﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

public partial class Users_TicketList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void SqlDataSource1_Init(object sender, EventArgs e)
    {
        SqlDataSource1.SelectParameters["UserID"].DefaultValue = Membership.GetUser().ProviderUserKey.ToString();
    }

    #region Confirm
    protected void lbConfirm_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            try
            {
                int ticketid = Convert.ToInt32(tbConfirm.Text);
                Response.Redirect("~/Users/ConfirmTicket.aspx?id=" + ticketid.ToString());
            }
            catch (Exception)
            {

            }
        }
    }

    protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
    {
        try
        {
            Convert.ToInt32(tbConfirm.Text);
            args.IsValid = true;
        }
        catch (Exception)
        {
            args.IsValid = false;
        }
    } 
    #endregion

    #region Cancel
    protected void lbCancel_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            try
            {
                int ticketid = Convert.ToInt32(tbCancel.Text);
                Response.Redirect("~/Users/CancleTicket.aspx?id=" + ticketid.ToString());
            }
            catch (Exception)
            {

            }
        }
    }
    
    protected void CustomValidator2_ServerValidate(object source, ServerValidateEventArgs args)
    {
        try
        {
            Convert.ToInt32(tbCancel.Text);
            args.IsValid = true;
        }
        catch (Exception)
        {
            args.IsValid = false;
        }
    } 
    #endregion

    protected void CustomValidator3_ServerValidate(object source, ServerValidateEventArgs args)
    {
        try
        {
            Convert.ToInt32(tbReschedule.Text);
            args.IsValid = true;
        }
        catch (Exception)
        {
            args.IsValid = false;
        }
    }

    protected void lbReschedule_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            try
            {
                int ticketid = Convert.ToInt32(tbReschedule.Text);
                Response.Redirect("~/Users/RescheduleTicket.aspx?id=" + ticketid.ToString());
            }
            catch (Exception)
            {

            }
        }
    }
}
